#include "message.h"

#include <algorithm>

namespace b2gdns {

	std::ostream& operator<<(std::ostream& os, Message const& m)
	{
		os << "m[";

		os << "h{";
		os << "id:" << m.header_.id << ",";
		os << "qr:" << m.header_.qr << ",";
		os << "opcode:" << m.header_.opcode << ",";
		os << "aa:" << m.header_.aa << ",";
		os << "tc:" << m.header_.tc << ",";
		os << "rd:" << m.header_.rd << ",";
		os << "ra:" << m.header_.ra << ",";
		os << "z:" << m.header_.z << ",";
		os << "rcode:" << m.header_.rcode << ",";
		os << "qdCount:" << m.header_.qdCount << ",";
		os << "anCount:" << m.header_.anCount << ",";
		os << "nsCount:" << m.header_.nsCount << ",";
		os << "arCount:" << m.header_.arCount << ",";
		os << "},";

		os << "q{";
		std::for_each(m.question_.begin(), m.question_.end(), [&os](std::string const& q)
		{
			os << q << ",";
		});
		os << "},";

		os << "]";
		return os;
	}

} // namespace b2gdns
